import Vue from 'vue'
import Router from 'vue-router'
import Layout from '@/layout'

Vue.use(Router)

export const constantRoutes = [
    {
        path: '/login',
        component: () => import('@/views/login/index'),
        hidden: true
    },
    {
        path: '/404',
        component: () => import('@/views/404'),
        hidden: true
    },
    {
        path: '/',
        component: Layout,
        redirect: '/users',
        children: [{
            path: 'study',
            name: '智慧体测记录算分系统',
            component: () => import('@/views/user/list'),
            meta: { title: '智慧体测记录算分系统' }
        }]
    },
    // { path: '*', redirect: '/404', hidden: true },

]

export const asyncRoutes = [
    {
        path: '/users',
        component: Layout,
        children: [
            {
                path: '',
                name: '用户管理',
                component: () => import('@/views/user/list'),
                meta: { title: '用户管理', icon: 'el-icon-user' }
            }
        ]
    },
    
    {
        path: '/fitness_project',
        component: Layout,
        children: [
            {
                path: '',
                name: '体测项目管理',
                component: () => import('@/views/project/list'),
                meta: { title: '体测项目管理', icon: 'el-icon-s-unfold' }
            }
        ]
    },
  
    {
        path: '/rec',
        component: Layout,
        children: [
            {
                path: '',
                name: '体测记录管理',
                component: () => import('@/views/rec/list'),
                meta: { title: '体测记录管理', icon: 'el-icon-s-data' }
            }
        ]
    },
    {
        path: '/scoring_standard',
        component: Layout,
        children: [
            {
                path: '',
                name: '评分计算',
                component: () => import('@/views/standard/list'),
                meta: { title: '评分计算管理', icon: 'el-icon-s-marketing' }
            }
        ]
    },
    {
        path: '/ai',
        component: Layout,
        children: [
            {
                path: '',
                name: 'AI智能分析管理',
                component: () => import('@/views/ai/list'),
                meta: { title: 'AI智能分析管理', icon: 'el-icon-magic-stick' }
            }
        ]
    },
    {
        path: '/kafka',
        component: Layout,
        children: [
            {
                path: '',
                name: '模拟数据输入',
                component: () => import('@/views/kafka/data'),
                meta: { title: '模拟数据输入', icon: 'el-icon-setting' }
            }
        ]
    },
]

export const userRoutes = [

    {
        path: '/users',
        component: Layout,
        children: [
            {
                path: '',
                name: '体测记录查询',
                component: () => import('@/views/rec/list'),
                meta: { title: '体测记录查询', icon: 'el-icon-s-data' }
            }
        ]
    },
    {
        path: '/scoring_standard',
        component: Layout,
        children: [
            {
                path: '',
                name: '评分查询',
                component: () => import('@/views/standard/list2'),
                meta: { title: '评分查询', icon: 'el-icon-s-marketing' }
            }
        ]
    },
    {
        path: '/ai',
        component: Layout,
        children: [
            {
                path: '',
                name: 'AI智能分析查询',
                component: () => import('@/views/ai/list'),
                meta: { title: 'AI智能分析查询', icon: 'el-icon-magic-stick' }
            }
        ]
    },


    

]

const createRouter = () => new Router({
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes
})

const router = createRouter()

export function resetRouter() {
    const newRouter = createRouter()
    router.matcher = newRouter.matcher // reset router
}

export default router
